---

- name: NEXUS | Copy nexus.vmptions
  template:
    src: "{{ nexus_vm_options_template }}"
    dest: "{{ nexus_installation_path }}/bin/nexus.vmoptions"
    mode: 0644
  notify: restart nexus

- name: NEXUS | Download composer repository plugin
  get_url:
    url: https://search.maven.org/remotecontent?filepath=org/sonatype/nexus/plugins/nexus-repository-composer/{{ item.plugin_version }}/nexus-repository-composer-{{ item.plugin_version }}-bundle.kar
    dest: "{{ nexus_installation_path }}/deploy"
  notify: restart nexus
  with_items:
    - "{{ nexus_repositories_composer }}"

- name: NEXUS | Copy configuration
  template:
    src: nexus.properties.j2
    dest: "{{ nexus_data_path }}/etc/nexus.properties"
    owner: "{{ nexus_user }}"
    group: "{{ nexus_group }}"
  notify: restart nexus

- name: NEXUS | First-time install admin password
  set_fact:
    current_nexus_admin_password: 'admin123'
  when: nexus_check is failed

- name: NEXUS | Actual admin password
  set_fact:
    current_nexus_admin_password: "{{ nexus_admin_password }}"
  when: nexus_check is success
  no_log: true
